<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@	taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>新建订单</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" href="/css/modules.css" type="text/css"	media="screen" />
	<link rel="stylesheet" href="/css/modules1.css" type="text/css"	media="screen" />
	<link rel="stylesheet" href="/css/jquery-ui.css" type="text/css"	media="screen" />
	<link rel="stylesheet" href="/css/jquery.wysiwyg.css" type="text/css"	media="screen" />
	<style type="text/css">
		label{
			display:inline;
			font-size:14px;
		}
		#orderForm .input-small{
			border:none;
			background-color:transparent;
		}
		.noborderSelect{
			border:none;
			background-color:transparent;
			width:100%;
		}
		#orderForm td{
			padding:0;
			text-align:center;
		}
		td_withPadding{
			padding:6px 6px 6px 12px;
		}
		#customerDetail td{
			padding:6px 6px 6px 12px;
			text-align:left;
			font-size:14px;
		}
		th{
			text-align:center;
		}
		.td_first{
		background: url("/images/highlight_line.gif") repeat-x scroll 0 0 #EAEAEA;
		}
		#selectCustomer{
			display:none;
		}
		h4{
			color:#CCC;
			font-size:12px;
			padding:10px;
			font-style:italic;
		}
		#createCustomer{
			display:none;
		}
	</style>
	<script type='text/javascript' src="/js/jquery-1.4.2.min.js"></script>	
	<script type='text/javascript' src="/js/jquery.js"></script>
	<script type='text/javascript' src="/js/jquery-ui.js"></script>
	<script type='text/javascript' src="/js/jquery.wysiwyg.js"></script>
	<script type='text/javascript' src="/js/custom.js"></script>
	<script type='text/javascript'>
		$(function(){
		
				$("#orderForm tr:eq(1)").hide();
			//	店铺选择加载店铺信息
			$("#outletsSelect").change(function(){
				var outletsid=$(this).val();
				if(outletsid!=""&&outletsid!=null){
					var url1="/OutletsAction!getInfo.action?outletsid=";
					$("#customerDetail").load(url1+outletsid);
				}else{
					$("#customerDetail").html("");
				}
			});
			
			//	数量变化改变金额
			$("#orderForm input[name='quantity']").blur(function(){
				var quan=$(this).val();
				var cur_tr_index=$(this).parent().parent().index("#orderForm tr")-1;
				var price=$("input[name='price']:eq("+cur_tr_index+")").val();
				if(price>0){
					var amount=quan*price;
					$("input[name='amounts']:eq("+cur_tr_index+")").val(amount);
				}
			});
		});
	
		var url;
		var dialogOption={height: 300,width:880,modal:true,position: [0,50]};
		var dialogOption1={height: 500,width:580,modal:true,position: [0,50]};
		
		
		function selectCustomer(){
			jQuery("#selectCustomer").dialog(dialogOption1);
			jQuery("#selectCustomer").dialog("open");
		}
		
		function customerSelected(f){
			var buttonValue=$(f).val();
			var selectValue=$("#outletsSelect").val();
			if(buttonValue=="确定"){
				if(selectValue!=null&&selectValue!=""){
					$("#hCustomerid").val(selectValue);
					jQuery("#selectCustomer").dialog("close");
					$("#addCustomButton").html("<label>收货人:"+$("#cusName").html()+"</label>"
					+"<input type='button'style='margin:10px;' value='变更收货人' class='button'" 
  					+"onclick='selectCustomer();'  >");
				}else{alert("请选择一个联系人!!");}
			}else{
				jQuery("#selectCustomer").dialog("close");
			}
			
		}
		
		//新建联系人
		function createCustomer(){
			jQuery("#selectCustomer").dialog("close");
			jQuery("#createCustomer").dialog(dialogOption);
			jQuery("#createCustomer").dialog("open");
		}
		
		//保存订单并直接发货
		function directDelivery(){
			$("#orderStatus").val("已发货");
			$("#orderForm").submit();
		}
		
		function addColume(){
		
			var xx=$("#orderForm tr:eq(1)").html();
			var addtr_index=$("#orderForm tr").size()-2;
			var addtr_index1=addtr_index+1;
			$("#orderForm tr:eq("+addtr_index+")").after("<tr><td class='td_first'>"+addtr_index+"</td>"+xx+"</tr>");
		}
	</script>
  </head>
  
  <body style="background-color:transparent">
	<!--  Goods_list header -->
	<div style="padding:10px;">
  		<h2 class="jquery_tab_title">发货单
  			<span style="float:right;">
  				<input type="text" class="input-medium" value="请输入订单编号" />
  				<input type="button" value="Search" class="button" />
  				<a href="##">订单查询</a>
  			</span>
  		</h2>
  		
  		<div id="addCustomButton">
  			<input type="button" style="margin:10px;" value="添加收货人" class="button" 
  				onclick="selectCustomer();" />
  		</div>
  	</div>
  	<!--  Goods_list  -->
  	<div>
    <form id="orderForm" action="/OrderAction!update.action" method="post">
    	<input id="hCustomerid" type="hidden" name="outletsid" />
    	<table  width="100%" cellspacing="0" cellpadding="0">
    		<tr>
    			<th class="th_first">行号</th>
    			<th width="30%">货物名称</th>
    			<th>数量</th>
    			<th>单价</th>
    			<th>金额</th>
    			<th>备注</th>
    		</tr>
    		<tr>
    			<td>
    				<s:select list="productList" listKey="id" listValue="name"
    				 theme="simple" headerKey="" headerValue="请选择货品" name="productid" cssClass="noborderSelect"></s:select>
    			</td>
    			<td><input type="text" name="quantity"  class="input-small"  /></td>
    			<td><input type="text" name="price"  class="input-small" /></td>
    			<td><input type="text" name="amounts"  class="input-small" /></td>
    			<td><input type="text" name="unit"  class="input-small" /></td>
    		</tr>
    		<tr>
    			<td class="td_first">1</td>
    			<td>
    				<s:select list="productList" listKey="id" listValue="name"
    				 theme="simple" headerKey="" headerValue="请选择货品" name="productid" cssClass="noborderSelect"></s:select>
    			</td>
    			<td><input type="text" name="quantity"  class="input-small"  /></td>
    			<td><input type="text" name="price"  class="input-small" /></td>
    			<td><input type="text" name="amounts"  class="input-small" /></td>
    			<td><input type="text" name="unit"  class="input-small" /></td>
    		</tr>
    		<tr>
    		<td class="td_first">2</td>
    			<td>
    				<s:select list="productList" listKey="id" listValue="name"
    				 theme="simple" headerKey="" headerValue="请选择货品" name="productid" cssClass="noborderSelect"></s:select>
    			</td>
    			<td><input type="text" name="quantity"  class="input-small"  /></td>
    			<td><input type="text" name="price"  class="input-small" /></td>
    			<td><input type="text" name="amounts"  class="input-small" /></td>
    			<td><input type="text" name="unit"  class="input-small" /></td>
    		</tr>
    		<tr>
    			<td class="td_first">3</td>
    			<td>
    				<s:select list="productList" listKey="id" listValue="name"
    				 theme="simple" headerKey="" headerValue="请选择货品" name="productid" cssClass="noborderSelect"></s:select>
    			</td>
    			<td><input type="text" name="quantity"  class="input-small"  /></td>
    			<td><input type="text" name="price"  class="input-small" /></td>
    			<td><input type="text" name="amounts"  class="input-small" /></td>
    			<td><input type="text" name="unit"  class="input-small" /></td>
    		</tr>
    		<tr>
    			<td class="td_first">4</td>
    			<td>
    				<s:select list="productList" listKey="id" listValue="name"
    				 theme="simple" headerKey="" headerValue="请选择货品" name="productid" cssClass="noborderSelect"></s:select>
    			</td>
    			<td><input type="text" name="quantity"  class="input-small"  /></td>
    			<td><input type="text" name="price"  class="input-small" /></td>
    			<td><input type="text" name="amounts"  class="input-small" /></td>
    			<td><input type="text" name="unit"  class="input-small" /></td>
    		</tr>
    		<tr>
    			<td class="td_first">5</td>
    			<td>
    				<s:select list="productList" listKey="id" listValue="name"
    				 theme="simple" headerKey="" headerValue="请选择货品" name="productid" cssClass="noborderSelect"></s:select>
    			</td>
    			<td><input type="text" name="quantity"  class="input-small"  /></td>
    			<td><input type="text" name="price"  class="input-small" /></td>
    			<td><input type="text" name="amounts"  class="input-small" /></td>
    			<td><input type="text" name="unit"  class="input-small" /></td>
    		</tr>
    		<tr>
    			<td class="td_first">6</td>
    			<td>
    				<s:select list="productList" listKey="id" listValue="name"
    				 theme="simple" headerKey="" headerValue="请选择货品" name="productid" cssClass="noborderSelect"></s:select>
    			</td>
    			<td><input type="text" name="quantity"  class="input-small"  /></td>
    			<td><input type="text" name="price"  class="input-small" /></td>
    			<td><input type="text" name="amounts"  class="input-small" /></td>
    			<td><input type="text" name="unit"  class="input-small" /></td>
    		</tr>
    		
    		<tr>
    			<td class="td_first" style="padding:6px 6px 6px 12px;">合计</td>
    			<td class="td_withPadding">&nbsp;</td>
    			<td class="td_withPadding">&nbsp;</td>
    			<td class="td_withPadding">&nbsp;</td>
    			<td class="td_withPadding">&nbsp;</td>
    			<td class="td_withPadding">&nbsp;</td>
    		</tr>
    		
    	</table>
    	<div style="padding:5px;"><label>备注:</label><input type="text" class="input-big" name="remark" /></div>
    	<div style="text-align:right">
    		<input type="submit" value="保存订单" class="button"/>
    		<input type="button" value="保存并发货" class="button" onclick="directDelivery()"/>
    		<input type="button" value="add" class="button" onclick="addColume();" />
    		<input type="hidden" id="orderStatus" name="status" value="未发货" />
    	</div>
    </form></div>
    
    
    <!-- 选择收货人 -->
    <div id="selectCustomer" title="选择收货人">
    	<div>
    	<span style="padding:5px;">
    		<a href="#" style="color:red;text-decoration:none;">直销店</a>
    	</span>
    	|<span style="padding:5px;"><a href="#" style="text-decoration:none;">批发客户</a></span>
    	<h4>---	* 选择联系人			-----------------------------</h4>
    	<span><label>直销店:</label>
    		<s:select id="outletsSelect" list="outletsList" listKey="id" listValue="name" 
    		headerKey="" headerValue="请选择联系人" theme="simple"></s:select>
    	<a href="##" onclick="createCustomer();">新建联系人</a></span><br />
    	<span style="text-align:right;padding-right:50px;display:block;padding:20px;">
    		<input type="button" class="button" value="确定" onclick="customerSelected(this);"/>
    		<input type="button" class="button" value="取消" onclick="customerSelected(this);"/>
    	</span>
    	</div>
   	 <div>
    	<h4>---	* 联系人基本资料		-----------------------------</h4>
    	<s:div href="#" id="customerDetail"></s:div>
    	</div>
    </div>
    
    <!-- 创建customer -->
    <div id="createCustomer" title="新建联系人">
    	<form action="CustomerAction!save.action" method="post">
    		<table id="noborder_table" width="100%" cellspacing="0" cellpadding="0">
  		<tr>
			<td>客户名称:</td>
			<td colspan="3" align="left">
				<input type="text" name="name" class="input-medium"/>
			</td>
			<td>当前应收款:</td>
			<td><input type="text" name="currentReceivables" class="input-small"/></td>			
		</tr>
		<tr>
			<td>联系人:</td>
			<td><input type="text" name="contact" class="input-small"/></td>
			<td>联系电话:</td>
			<td><input type="text" name="telphone" class="input-small"/></td>
			<td>初始应收款:</td>
			<td><input type="text" name="initReceivables" class="input-small"/></td>
		</tr>
		<tr>
			<td>传真:</td>
			<td><input type="text" name="fax" class="input-small"/></td>
			<td>QQ号码:</td>
			<td><input type="text" name="qicq" class="input-small"/></td>
			<td>电子邮件:</td>
			<td><input type="text" name="email" class="input-small"/></td>
		</tr>
		<tr>
			<td>地址:</td>
			<td colspan="3">	
				<input type="text" name="address" class="input-medium"/>
			</td>
			<td>邮政编码:</td>
			<td>
				<input type="text" name="postCode" class="input-small"/>
			</td>
		</tr>
		<tr>
			<td>备注:</td>
			<td colspan="5">
				<input type="text" name="remark" class="input-big"/>
			</td>
		</tr>
  		<tr>
  			<td colspan="2"></td>
  			<td>
  				<input type="submit" value="确定" class="button"/>
  				<input type="button" value="取消" class="button"/>
  			</td>
  		</tr>
  	</table>
    	</form>
    </div>
  </body>
</html>
